<?php

namespace AdminsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Product
 *
 * @ORM\Table(name="product")
 * @ORM\Entity(repositoryClass="AdminsBundle\Repository\ProductRepository")
 */
class Product
{
    /**
     * @var int
     *
     * @ORM\Column(name="product_id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var int
     *
     * @ORM\Column(name="product_cid", type="integer")
     */
    private $cid;

    /**
     * @var string
     *
     * @ORM\Column(name="product_no", type="string", length=50 , unique=true )
     */
    private $no;

    /**
     * @var string
     *
     * @ORM\Column(name="product_name", type="string", length=255)
     */
    private $name;

    /**
     * @var int
     *
     * @ORM\Column(name="product_price", type="integer")
     */
    private $price;

    /**
     * @var int
     *
     * @ORM\Column(name="product_market_price", type="integer")
     */
    private $marketPrice = 1;

    /**
     * @var int
     *
     * @ORM\Column(name="product_stock_price", type="integer")
     */
    private $stockPrice;

    /**
     * @var int
     *
     * @ORM\Column(name="product_num", type="integer")
     */
    private $num = 0;

    /**
     * @var string
     *
     * @ORM\Column(name="product_search_info", type="text")
     */
    private $searchInfo;

    public function __construct()
    {
        $this->no = substr(date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8),2,14);
    }

    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set cid
     *
     * @param integer $cid
     *
     * @return Product
     */
    public function setCid($cid)
    {
        $this->cid = $cid;

        return $this;
    }

    /**
     * Get cid
     *
     * @return int
     */
    public function getCid()
    {
        return $this->cid;
    }

    /**
     * Set no
     *
     * @param string $no
     *
     * @return Product
     */
    public function setNo($no)
    {
        $this->no = $no;

        return $this;
    }

    /**
     * Get no
     *
     * @return string
     */
    public function getNo()
    {
        return $this->no;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return Product
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set price
     *
     * @param integer $price
     *
     * @return Product
     */
    public function setPrice($price)
    {
        $this->price = floor($price * 100);

        return $this;
    }

    /**
     * Get price
     *
     * @return int
     */
    public function getPrice()
    {
        return $this->price/100;
    }

    /**
     * Set marketPrice
     *
     * @param integer $marketPrice
     *
     * @return Product
     */
    public function setMarketPrice($marketPrice)
    {
        $this->marketPrice = floor($marketPrice * 100);

        return $this;
    }

    /**
     * Get marketPrice
     *
     * @return int
     */
    public function getMarketPrice()
    {
        return $this->marketPrice/100;
    }

    /**
     * Set stockPrice
     *
     * @param integer $stockPrice
     *
     * @return Product
     */
    public function setStockPrice($stockPrice)
    {
        $this->stockPrice = floor($stockPrice * 100);

        return $this;
    }

    /**
     * Get stockPrice
     *
     * @return int
     */
    public function getStockPrice()
    {
        return $this->stockPrice/100;
    }

    /**
     * Set num
     *
     * @param integer $num
     *
     * @return Product
     */
    public function setNum($num)
    {
        $this->num = $num;

        return $this;
    }

    /**
     * Get num
     *
     * @return int
     */
    public function getNum()
    {
        return $this->num;
    }

    /**
     * Set searchInfo
     *
     * @param string $searchInfo
     *
     * @return Product
     */
    public function setSearchInfo($searchInfo)
    {
        $this->searchInfo = $searchInfo;

        return $this;
    }

    /**
     * Get searchInfo
     *
     * @return string
     */
    public function getSearchInfo()
    {
        return $this->searchInfo;
    }
}
